package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {
    //累计用户数
    @Select("SELECT SUM(num_registered) FROM tb_analysis_by_day")
    Long findTotalUserCount();

    //统计一段时间内的活跃用户数量
    @Select("SELECT SUM(num_active) FROM tb_analysis_by_day WHERE record_date BETWEEN #{start} AND #{end}")
    Long findActiveCountInPeriod(@Param("start")String start,@Param("end")String end);

    //统计指定时间的数据
    @Select("SELECT * FROM tb_analysis_by_day WHERE record_date = #{recordDate}")
    AnalysisByDay findByRecordDate(String recordDate);

}